1 /*********************************************************************************************************************
2 * @file startup_XMC1400.S
3 * @brief CMSIS Core Device Startup File for Infineon XMC1400 Device Series
8 *********************************************************************************************************************
9 * Copyright (c) 2015-2017, Infineon Technologies AG
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
13 * following conditions are met:
15 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
18 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided with the distribution.
21 * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
22 * products derived from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with
33 * Infineon Technologies AG dave@infineon.com).
34 *********************************************************************************************************************
36 **************************** Change history ********************************
37 * V1.0, Sep, 03, 2015 JFT:Initial version
38 * MCLK=8MHz, PCLK=16MHz
39 * V1.1, Jan, 05, 2016 JFT:Fix .reset section attributes
40 * V1.2, Sep, 15, 2017 JFT:Added option to select wait time before ASC BSL channel selection (WAIT_ASCBSL_ENTRY_SSW)
45 /*****************************************************************************
46 * <h> Clock system handling by SSW
47 * <h> CLK_VAL1 Configuration
48 * <o0.0..9> FDIV Fractional Divider Selection <0-1023>
49 * <i> Deafult: 0. Fractional part of clock divider, MCLK = DCO1 / (IDIV + (FDIV / 1024))
50 * <o0.10..17> IDIV Divider Selection <1-16>
51 * <i> Deafult: 6. Interger part of clock divider, MCLK = DCO1 / (IDIV + (FDIV / 1024) = 8MHz)
52 * <o0.18> PCLKSEL PCLK Clock Select
54 * <1=> PCLK = 2 x MCLK
55 * <i> Deafult: 2 x MCLK
56 * <o0.19..21> RTCCLKSEL RTC Clock Select
57 * <0=> 32.768kHz standby clock
58 * <1=> 32.768kHz external clock from ERU0.IOUT0
59 * <2=> 32.768kHz external clock from ACMP0.OUT
60 * <3=> 32.768kHz external clock from ACMP1.OUT
61 * <4=> 32.768kHz external clock from ACMP2.OUT
62 * <5=> 32.768kHz XTAL clock via OSC_LP
65 * <i> Deafult: 32.768kHz standby clock
66 * <o0.31> do not move CLK_VAL1 to SCU_CLKCR[0..19]
68 *****************************************************************************/
69 #define CLKVAL1_SSW 0x00041800
71 /*****************************************************************************
72 * <h> CLK_VAL2 Configuration
73 * <o0.0> disable VADC and SHS Gating
74 * <o0.1> disable CCU80 Gating
75 * <o0.2> disable CCU40 Gating
76 * <o0.3> disable USIC0 Gating
77 * <o0.4> disable BCCU0 Gating
78 * <o0.5> disable LEDTS0 Gating
79 * <o0.6> disable LEDTS1 Gating
80 * <o0.7> disable POSIF0 Gating
81 * <o0.8> disable MATH Gating
82 * <o0.9> disable WDT Gating
83 * <o0.10> disable RTC Gating
84 * <o0.16> disable CCU81 Gating
85 * <o0.17> disable CCU41 Gating
86 * <o0.18> disable USIC1 Gating
87 * <o0.19> disable LEDTS2 Gating
88 * <o0.20> disable POSIF1 Gating
89 * <o0.21> disable MCAN0 Gating
90 * <o0.31> do not move CLK_VAL2 to SCU_CGATCLR0[0..10]
92 *****************************************************************************/
93 #define CLKVAL2_SSW 0x00000100
95 /*****************************************************************************
96 * <h> WAIT_ASCBSL_ENTRY Configuration
97 * <o0.0..30> Wait time before ASC BSL channel selection (number of MCLK clock cycles)
98 * <o0.31> Disable wait time before ASC BSL channel selection
100 *****************************************************************************/
101 #define WAIT_ASCBSL_ENTRY_SSW 0x80000000
103 /* A couple of macros to ease definition of the various handlers */
104 .macro Insert_InterruptHandler Interrupt
105 .weak \Interrupt\()_Handler
106 .thumb_set \Interrupt\()_Handler, Default_Handler
109 .macro Insert_InterruptVeener Interrupt
110 .globl \Interrupt\()_Veener
111 \Interrupt\()_Veener:
112 LDR R0, =\Interrupt\()_Handler
116 /* ================== START OF VECTOR TABLE DEFINITION ====================== */
117 /* Vector Table - This is indirectly branched to through the veneers */
121 .section .reset, "a", %progbits
126 .type __Vectors, %object
128 .long __initial_sp /* Top of Stack */
129 .long Reset_Handler /* Reset Handler */
131 * All entries below are redundant for M0, but are retained because they can
132 * in the future be directly ported to M0 Plus devices.
134 .long 0 /* Reserved */
135 .long HardFault_Handler /* Hard Fault Handler */
136 .long CLKVAL1_SSW /* Reserved */
137 .long CLKVAL2_SSW /* Reserved */
138 .long WAIT_ASCBSL_ENTRY_SSW /* Reserved */
139 #ifdef RETAIN_VECTOR_TABLE
140 .long 0 /* Reserved */
141 .long 0 /* Reserved */
142 .long 0 /* Reserved */
143 .long 0 /* Reserved */
144 .long SVC_Handler /* SVCall Handler */
145 .long 0 /* Reserved */
146 .long 0 /* Reserved */
147 .long PendSV_Handler /* PendSV Handler */
148 .long SysTick_Handler /* SysTick Handler */
150 /* Interrupt Handlers for Service Requests (SR) from XMC1400 Peripherals */
151 .long IRQ0_Handler /* SCU.SR0, CAN0.SR0, CCU40.SR0, SCU.SR0 | CAN0.SR0 */
152 .long IRQ1_Handler /* SCU.SR1, CAN0.SR1, CCU80.SR0, SCU.SR1 | CAN0.SR1 */
153 .long IRQ2_Handler /* SCU.SR2, CAN0.SR2, CCU80.SR1, SCU.SR2 | CAN0.SR2 */
154 .long IRQ3_Handler /* ERU0.SR0, ERU1.SR0, CAN0.SR0, ERU0.SR0 | ERU1.SR0 */
155 .long IRQ4_Handler /* ERU0.SR1, ERU1.SR1, CAN0.SR1, ERU0.SR1 | ERU1.SR1 */
156 .long IRQ5_Handler /* ERU0.SR2, ERU1.SR2, CAN0.SR2, ERU0.SR2 | ERU1.SR2 */
157 .long IRQ6_Handler /* ERU0.SR3, ERU1.SR3, CAN0.SR3, ERU0.SR3 | ERU1.SR3 */
158 .long IRQ7_Handler /* MATH.SR0, CAN0.SR3, CCU40.SR1, MATH.SR0 | CAN0.SR3 */
159 .long IRQ8_Handler /* LEDTS2.SR0, CCU40.SR0, CCU80.SR0, LEDTS2.SR0 | CCU40.SR0 */
160 .long IRQ9_Handler /* USIC0.SR0, USIC1.SR0, ERU0.SR0, USIC0.SR0 | USIC1.SR0 */
161 .long IRQ10_Handler /* USIC0.SR1, USIC1.SR1, ERU0.SR1, USIC0.SR1 | USIC1.SR1 */
162 .long IRQ11_Handler /* USIC0.SR2, USIC1.SR2, ERU0.SR2, USIC0.SR2 | USIC1.SR2 */
163 .long IRQ12_Handler /* USIC0.SR3, USIC1.SR3, ERU0.SR3, USIC0.SR3 | USIC1.SR3 */
164 .long IRQ13_Handler /* USIC0.SR4, USIC1.SR4, CCU80.SR1, USIC0.SR4 | USIC1.SR4 */
165 .long IRQ14_Handler /* USIC0.SR5, USIC1.SR5, POSIF0.SR0, USIC0.SR5 | USIC1.SR5 */
166 .long IRQ15_Handler /* VADC0.C0SR0, USIC0.SR0, POSIF0.SR1, VADC0.C0SR0 | USIC0.SR0 */
167 .long IRQ16_Handler /* VADC0.C0SR1, USIC0.SR1, CCU40.SR2, VADC0.C0SR1 | USIC0.SR1 */
168 .long IRQ17_Handler /* VADC0.G0SR0, USIC0.SR2, CAN0.SR0, VADC0.G0SR0 | USIC0.SR2 */
169 .long IRQ18_Handler /* VADC0.G0SR1, USIC0.SR3, CAN0.SR1, VADC0.G0SR1 | USIC0.SR3 */
170 .long IRQ19_Handler /* VADC0.G1SR0, USIC0.SR4, CAN0.SR2, VADC0.G1SR0 | USIC0.SR4 */
171 .long IRQ20_Handler /* VADC0.G1SR1, USIC0.SR5, CAN0.SR3, VADC0.G1SR1 | USIC0.SR5 */
172 .long IRQ21_Handler /* CCU40.SR0, CCU41.SR0, USIC0.SR0, CCU40.SR0 | CCU41.SR0 */
173 .long IRQ22_Handler /* CCU40.SR1, CCU41.SR1, USIC0.SR1, CCU40.SR1 | CCU41.SR1 */
174 .long IRQ23_Handler /* CCU40.SR2, CCU41.SR2, USIC0.SR2, CCU40.SR2 | CCU41.SR2 */
175 .long IRQ24_Handler /* CCU40.SR3, CCU41.SR3, USIC0.SR3, CCU40.SR3 | CCU41.SR3 */
176 .long IRQ25_Handler /* CCU80.SR0, CCU81.SR0, USIC0.SR4, CCU80.SR0 | CCU81.SR0 */
177 .long IRQ26_Handler /* CCU80.SR1, CCU81.SR1, USIC0.SR5, CCU80.SR1 | CCU81.SR1 */
178 .long IRQ27_Handler /* POSIF0.SR0, POSIF1.SR0, CCU40.SR3, POSIF0.SR0 | POSIF1.SR0 */
179 .long IRQ28_Handler /* POSIF0.SR1, POSIF1.SR1, ERU0.SR0, POSIF0.SR1 | POSIF1.SR1 */
180 .long IRQ29_Handler /* LEDTS0.SR0, CCU40.SR1, ERU0.SR1, LEDTS0.SR0 | CCU40.SR1 */
181 .long IRQ30_Handler /* LEDTS1.SR0, CCU40.SR2, ERU0.SR2, LEDTS1.SR0 | CCU40.SR2 */
182 .long IRQ31_Handler /* BCCU0.SR0, CCU40.SR3, ERU0.SR3, BCCU0.SR0 | CCU40.SR3 */
185 .size __Vectors, . - __Vectors
186 /* ================== END OF VECTOR TABLE DEFINITION ======================= */
188 /* ================== START OF VECTOR ROUTINES ============================= */
196 .type Reset_Handler, %function
198 /* Initialize interrupt veneer */
207 /* Initialize data */
208 ldr r1, =DataLoadAddr
209 ldr r2, =__data_start
214 ldr r1, =__ram_code_load
215 ldr r2, =__ram_code_start
216 ldr r3, =__ram_code_end
219 /* Define __SKIP_BSS_CLEAR to disable zeroing uninitialzed data in startup.
220 * The BSS section is specified by following symbols
221 * __bss_start__: start of the BSS section.
222 * __bss_end__: end of the BSS section.
224 * Both addresses must be aligned to 4 bytes boundary.
226 #ifndef __SKIP_BSS_CLEAR
240 #endif /* __SKIP_BSS_CLEAR */
242 #ifndef __SKIP_LIBC_INIT_ARRAY
243 ldr r0, =__libc_init_array
251 .type __copy_data, %function
253 /* The ranges of copy from/to are specified by following symbols
254 * r1: start of the section to copy from.
255 * r2: start of the section to copy to
256 * r3: end of the section to copy to
258 * All addresses must be aligned to 4 bytes boundary.
274 .size Reset_Handler,.-Reset_Handler
275 /* ======================================================================== */
276 /* ========== START OF EXCEPTION HANDLER DEFINITION ======================== */
281 .weak Default_handler
282 .type Default_handler, %function
285 .size Default_Handler, . - Default_Handler
287 Insert_InterruptHandler HardFault
288 Insert_InterruptHandler SVC
289 Insert_InterruptHandler PendSV
290 Insert_InterruptHandler SysTick
292 Insert_InterruptHandler IRQ0
293 Insert_InterruptHandler IRQ1
294 Insert_InterruptHandler IRQ2
295 Insert_InterruptHandler IRQ3
296 Insert_InterruptHandler IRQ4
297 Insert_InterruptHandler IRQ5
298 Insert_InterruptHandler IRQ6
299 Insert_InterruptHandler IRQ7
300 Insert_InterruptHandler IRQ8
301 Insert_InterruptHandler IRQ9
302 Insert_InterruptHandler IRQ10
303 Insert_InterruptHandler IRQ11
304 Insert_InterruptHandler IRQ12
305 Insert_InterruptHandler IRQ13
306 Insert_InterruptHandler IRQ14
307 Insert_InterruptHandler IRQ15
308 Insert_InterruptHandler IRQ16
309 Insert_InterruptHandler IRQ17
310 Insert_InterruptHandler IRQ18
311 Insert_InterruptHandler IRQ19
312 Insert_InterruptHandler IRQ20
313 Insert_InterruptHandler IRQ21
314 Insert_InterruptHandler IRQ22
315 Insert_InterruptHandler IRQ23
316 Insert_InterruptHandler IRQ24
317 Insert_InterruptHandler IRQ25
318 Insert_InterruptHandler IRQ26
319 Insert_InterruptHandler IRQ27
320 Insert_InterruptHandler IRQ28
321 Insert_InterruptHandler IRQ29
322 Insert_InterruptHandler IRQ30
323 Insert_InterruptHandler IRQ31
325 /* ======================================================================== */
327 /* ==================VENEERS VENEERS VENEERS VENEERS VENEERS=============== */
328 .section ".XmcVeneerCode","ax",%progbits
332 Insert_InterruptVeener HardFault
340 Insert_InterruptVeener SVC
343 Insert_InterruptVeener PendSV
344 Insert_InterruptVeener SysTick
346 Insert_InterruptVeener IRQ0
347 Insert_InterruptVeener IRQ1
348 Insert_InterruptVeener IRQ2
349 Insert_InterruptVeener IRQ3
350 Insert_InterruptVeener IRQ4
351 Insert_InterruptVeener IRQ5
352 Insert_InterruptVeener IRQ6
353 Insert_InterruptVeener IRQ7
354 Insert_InterruptVeener IRQ8
355 Insert_InterruptVeener IRQ9
356 Insert_InterruptVeener IRQ10
357 Insert_InterruptVeener IRQ11
358 Insert_InterruptVeener IRQ12
359 Insert_InterruptVeener IRQ13
360 Insert_InterruptVeener IRQ14
361 Insert_InterruptVeener IRQ15
362 Insert_InterruptVeener IRQ16
363 Insert_InterruptVeener IRQ17
364 Insert_InterruptVeener IRQ18
365 Insert_InterruptVeener IRQ19
366 Insert_InterruptVeener IRQ20
367 Insert_InterruptVeener IRQ21
368 Insert_InterruptVeener IRQ22
369 Insert_InterruptVeener IRQ23
370 Insert_InterruptVeener IRQ24
371 Insert_InterruptVeener IRQ25
372 Insert_InterruptVeener IRQ26
373 Insert_InterruptVeener IRQ27
374 Insert_InterruptVeener IRQ28
375 Insert_InterruptVeener IRQ29
376 Insert_InterruptVeener IRQ30
377 Insert_InterruptVeener IRQ31
379 /* ======================================================================== */
380 /* ======================================================================== */
382 /* ============= END OF INTERRUPT HANDLER DEFINITION ======================== */